{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "TLV320AIC3204に内臓されている1st order IIR Filterを使って、DCリジェクション(HPF) b0,b1,a1の三つの係数を決定する。\n",
    "符号付き24ビット整数。a1の符号が反対になることに留意。16進表記に変更するのが面倒。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import pylab as pl\n",
    "import numpy as np\n",
    "from scipy import signal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def mfreqz(b,a=1):\n",
    "    w,h = signal.freqz(b,a)\n",
    "    h_dB = 20 * np.log10 (abs(h))\n",
    "    pl.subplot(211)\n",
    "    pl.plot(w/max(w),h_dB)\n",
    "    pl.ylim(-80, 5)\n",
    "    pl.ylabel('Magnitude (db)')\n",
    "    pl.xlabel(r'Normalized Frequency (x$\\pi$rad/sample)')\n",
    "    pl.title(r'Frequency response')\n",
    "    pl.subplot(212)\n",
    "    h_Phase = np.unwrap(np.arctan2(np.imag(h),np.real(h)))\n",
    "    pl.plot(w/np.max(w),h_Phase)\n",
    "    pl.ylabel('Phase (radians)')\n",
    "    pl.xlabel(r'Normalized Frequency (x$\\pi$rad/sample)')\n",
    "    pl.title(r'Phase response')\n",
    "    pl.subplots_adjust(hspace=0.5)\n",
    "    pl.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1次のHPF。fc=0.0001*(fs/2) を指定。fs=48kHzなら、fc=2.4Hz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 0.99984295, -0.99984295]), array([ 1.        , -0.99968589]))"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b, a = signal.iirfilter(1, [0.0001], btype='highpass')\n",
    "b, a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel_launcher.py:7: RuntimeWarning: divide by zero encountered in log10\n",
      "  import sys\n",
      "/usr/local/lib/python2.7/site-packages/ipykernel_launcher.py:7: RuntimeWarning: invalid value encountered in multiply\n",
      "  import sys\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEPCAYAAACzwehFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHLdJREFUeJzt3XuUVOWZ7/Hvg6ABQfESb9xaAgJqtEXHW2LSJ7qUnBhv\nkxydnBXT6riSeHQSj8lEoxknlzOJOsEzY+Ja5qKMTowa491ohMHO0XgXSkQaRaUFxLugICpCP+eP\nt/AtG+jq7t3V767av89ae1W9tXftenjsVY/7ffbeZe6OiIhIdwalDkBERPJPxUJERKpSsRARkapU\nLEREpCoVCxERqUrFQkREqhqcOoDumFkH8BbQCXzg7gemjUhEpJhyXSwIRaLF3VekDkREpMjyPg1l\n5D9GEZGGl/cvYgdmmtmjZnZ66mBERIoq79NQn3L3l8zs44Si0e7u96cOSkSkaHJdLNz9pfLja2Z2\nM3Ag8GGxMDPd2EpEpA/c3XqzfW6nocxsmJkNLz/fGjgSmN91O3fX4s6FF16YPIa8LMqFcqFcdL/0\nRZ6PLHYGbi4fPQwGfufu9ySOKbc6OjpSh5AbykWkXETKRTa5LRbuvhhoTh2HiIjkeBpKeqe1tTV1\nCLmhXETKRaRcZGN9nb/KAzPzeo5fRCQFM8MbpcEtvdPW1pY6hNxQLiLlIlIuslGxEBGRqjQNJSJS\nMJqGEhGRmlCxaBCaj42Ui0i5iJSLbFQsRESkKvUsREQKRj0LERGpCRWLBqH52Ei5iJSLSLnIRsVC\nRESqUs9CRKRg1LMQEZGaULFoEJqPjZSLSLmIlItsVCxER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CDk0cU2qv\nmNnOAGa2C/BqtTfUa7F4FJhgZuPKZzWcRLiYr6iuBBa4+7+lDiQVd/++u4919/GEv4fZ7n5y6rhS\nKU8xLC1fywRwOMVt/D8NHGxmHyvfwfpwitfs73q0fRvQWn7+NcKdv7uV9EaCfeXu683sTOAeQsH7\nrbsX7T8+AGb2KeB/Ak+a2VzC4eT33f3utJFJDvwD4W4IQwgXvp6SOJ4k3P2J8lHm44SLgOcCv0ob\n1cAxs2uBFmAHM1tC+DmInwF/MLNTgRcIPwvR/X50UZ6IiFRTr9NQIiIygFQsRESkKhULERGpSsVC\nRESqUrEQEZGqVCxERKQqFQuRjMxsVZfx18zsslTxiNSCioVIdpu6WEkXMElDqcsruEXqRcVV9QZM\nAo5y9/vSRiXSeyoWItkNM7M55ecGbEf5XmXuvh+AmR1NuH36A0kiFMlIxUIkuzXl24ADoWcB7F8x\nnghcAny2fNdTkbqjnoVIDZV/Z+R64DR3r3obaJG8UrEQya67H1q6ErjS3TX9JHVNxUIku02e+WRm\nY4ETgFPNbG75502L+gNEUud0i3IREalKRxYiIlKVioWIiFSlYiEiIlWpWIiISFUqFiIiUpWKhYiI\nVKViISIiValYiIhIVf8fctaNAiq78NgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x114d5ad50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fs = 48e3\n",
    "w,h = signal.freqz(b, a, worN=1<<18)\n",
    "pl.grid()\n",
    "pl.xlim(0,10)\n",
    "pl.xlabel(\"Hz\")\n",
    "pl.ylabel(\"dB\")\n",
    "pl.plot((fs/2) * w / np.pi/2, 20*np.log10(h));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEHCAYAAACncpHfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGuBJRE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ftrs37\nREQkBYqZAKz5Z5vFwBFm1s3MOpGc6jnHZ3AiIlI5hZ4GOg1YQNLUXWNm/+mcawSuBJ4EXgBmOOeW\nVS5UERHxKYq1gEREpPqiXQvIzPqZ2f1mNt3MvhY6nrQzs8PN7EEzmxU6lrQzs33MbLKZ3WdmF4aO\nJ830vfSr2HEz+iMAM+sMjHHOXRI6liwws1nOufNDx5Fmzac8v++ce8TMZjjnBoSOKe30vfSr0HGz\n4kcA5Swj0ezHwPjKRpkeHvIpLZSQ067Aq81/bqxaoCmg76dfZeSzoHGzGiWgUpeRONjMbgUedc5p\nBakdSl6WY9vTqxlsShSVU5LBv+u2p1YryJQoNpfbn1ad8FKn6HwWM25WfAIoYxmJc4FTgfPM7NJK\nx5kWZeRzi5ndC/TWb2C7KjanwG9IvpfjgbnVizR+xebSzA7U97JtJeTzSooYN0NdCfwZdhxCA7xG\n8pfazjk3DhhXzaBSrJB8vgcMrWZQKddmTp1zG4EhIYJKqfZyqe9l8drLZ1HjZrRnAYmISGWFmgC0\njIRfyqd/yqk/yqVf3vJZrQlAy0j4pXz6p5z6o1z6VbF8VuM0UC0j4ZHy6Z9y6o9y6Vel8xn9hWAi\nIlIZagKLiNQoTQAiIjVKE4CISI3SBCAiUqM0AYiI1ChNACIiNUoTgIhIjdIEICJSozQBiIjUqP8H\nOwa3Dz9V3wQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x114d5a150>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pl.xlim((1e-2, 1e2))\n",
    "pl.grid()\n",
    "pl.loglog((fs/2) * w / np.pi/2, h);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 8388608., -8385973.]), array([ 8387291., -8387291.]))"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.rint(a * 2**23), np.rint(b * 2**23)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "al = list(np.vectorize(int)(a * 2**23))\n",
    "bl = list(np.vectorize(int)(b * 2**23))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def to_bytes(n, length):\n",
    "    return [(n >> i*8) & 0xff for i in reversed(range(length))]\n",
    "def to_hex(n):\n",
    "    return \", \".join([hex(int(x)) for x in to_bytes(n, 3)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['0x7f, 0xfa, 0xda', '0x80, 0x5, 0x26']"
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[to_hex(x) for x in bl]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0x7f, 0xf5, 0xb5'"
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "to_hex(-al[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
